Option Strict Off
Option Explicit On
Module ErrorHandling
	'This routine handles the printing to the ErrorLog.txt file
	
	
	Private Declare Function lOpen Lib "kernel32"  Alias "_lopen"(ByVal lpPathName As String, ByVal iReadWrite As Integer) As Integer
	Private Declare Function lClose Lib "kernel32"  Alias "_lclose"(ByVal hFile As Integer) As Integer
	
	Public Sub ErrPnt(ByRef ErrorPoint As String)
		ErrorCodeNo = ErrorPoint 'set the errorcodenumber in case the program crashes (see frmErrorbox)
		
		If ErrorLoggingYesNO = False Then Exit Sub 'Check if error logging is on
		
		On Error Resume Next
		FileOpen(181, My.Application.Info.DirectoryPath & "/Errorlog.txt", OpenMode.Output) 'Open the file, it may be already open, so on error above just continues
		
		
		
		'Now handle any special points such as start and end of capturing etc.
		If ErrorCodeNo = "2.00" Then
			Print(181, "Capturing Frame " & FrameNum & " " & ErrorCodeNo & " ") 'No carriage return after this text
			Exit Sub
		End If
		If ErrorCodeNo = "2.99" Then
			PrintLine(181, ErrorCodeNo & " End of Capture OK")
			Exit Sub
		End If
		If ErrorCodeNo = "5.00" Then
			Print(181, "Entering Editor " & ErrorCodeNo & " ") 'No carriage return after this text
			Exit Sub
		End If
		If ErrorCodeNo = "5.99" Then
			PrintLine(181, ErrorCodeNo & " Exiting Editor")
			Exit Sub
		End If
		
		'Otherwise just print the position in the program to the text file
		Print(181, ErrorCodeNo & " ")
		
	End Sub
End Module